import { WebSocketServer } from 'ws'

const wss = new WebSocketServer({ port: 3001 })
wss.on('connection', (ws) => {
  ws.on('error', console.error)

  ws.on('message', (data) => {
    console.log('已收到: %s', data)
  })

  ws.send('服务器: hello world')
})

export { wss }
